package cn.highedu.coolshark.account.controller;

import cn.highedu.coolshark.account.service.LogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
public class LogController {

    @Autowired
    private LogService logService;

    /**
     * 请求 /admin/log 时，必须具有 ADMIN 角色才能访问
     */
    @GetMapping("/admin/log")
    public String adminLog() {
        log.debug("请求 /admin/log");
        logService.adminLog();
        return "admin log";
    }

    /**
     * 请求 /manager/log 时，必须具有 MANAGER 角色才能访问
     */
    @GetMapping("/manager/log")
    public String managerLog() {
        log.debug("请求 /manager/log");
        logService.managerLog();
        return "manager log";
    }

    /**
     * 请求 /log/query 时，必须具有 sys:log:query 权限才能访问
     */
    @GetMapping("/log/query")
    public String queryList() {
        log.debug("请求 /log/query");
        logService.queryList();
        return "query log";
    }

    /**
     * 请求 /log/delete 时，必须具有 sys:log:delete 权限才能访问
     */
    @GetMapping("/log/delete")
    public String delete() {
        log.debug("请求 /log/delete");
        logService.delete();
        return "delete log";
    }

}
